package com.telecom.entity;

import lombok.Data;

import java.util.Map;
@Data
public class Subway {

    private Map<String,Integer>  stations;
    public int charge(String start,String end){
        int startValue=0;
        int endValue=0;
        for (Map.Entry<String, Integer> entry : stations.entrySet()) {
            if(entry.getKey().equals(start)){
                startValue=entry.getValue();
            }
            if(entry.getKey().equals(end)){
                endValue=entry.getValue();
            }
        }
        //取绝对值
        int distance=Math.abs(startValue-endValue);
        if (distance<=3){
            return 2;
        }else if (distance<=5) {
            return 3;
        }else{
            return 4;
        }
    }
}
